package com.chunfeng.mypen.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

/**
 * 用户实体类
 *
 * @author by 春风能解释
 * <p>
 * 2023/11/13
 */
@Data
@NoArgsConstructor
@ApiModel(value = "用户实体", description = "用于存储用户的信息")
public class User implements Serializable {
    /**
     * 序列化常量
     */
    @ApiModelProperty(value = "序列化字段", hidden = true)
    private static final long serialVersionUID = -2129771814977053812L;
    /**
     * 主键
     */
    @ApiModelProperty(value = "用户ID", allowEmptyValue = true)
    private String id;
    /**
     * 用户名
     */
    @ApiModelProperty(value = "用户名")
    private String name;
    /**
     * 密码
     */
    @ApiModelProperty(value = "密码")
    private String password;
    /**
     * 昵称
     */
    @ApiModelProperty(value = "昵称")
    private String nickname;
    /**
     * 性别(0女1男)
     */
    @ApiModelProperty(value = "性别", allowableValues = "0,1", allowEmptyValue = true)
    private Integer sex;
    /**
     * 手机号
     */
    @ApiModelProperty(value = "手机号", allowEmptyValue = true)
    private String phone;
    /**
     * 电子邮件
     */
    @ApiModelProperty(value = "电子邮件", allowEmptyValue = true)
    private String email;
    /**
     * 权限列表(连表信息)
     */
    @TableField(exist = false)
    @ApiModelProperty(value = "权限列表", allowEmptyValue = true)
    private List<String> permissionList;
    /**
     * 是否冻结(0正常,1冻结)
     */
    @ApiModelProperty(value = "是否冻结", allowableValues = "0,1")
    private Integer freeze;
    /**
     * 头像
     */
    @ApiModelProperty(value = "头像", allowEmptyValue = true)
    private String fileId;
    /**
     * 角色ID
     */
    @ApiModelProperty(value = "角色ID")
    private String roleId;
    /**
     * 状态(0正常,1失效)
     */
    @ApiModelProperty(value = "状态(0正常,1失效)", allowableValues = "0,1")
    @TableLogic
    private Integer status;
    /**
     * 创建人
     */
    @ApiModelProperty(value = "创建人", hidden = true)
    @TableField(fill = FieldFill.INSERT)
    private String createUser;
    /**
     * 更新人
     */
    @ApiModelProperty(value = "更新人", hidden = true)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String updateUser;
    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间", hidden = true)
    @TableField(fill = FieldFill.INSERT)
    private String createTime;
    /**
     * 修改时间
     */
    @ApiModelProperty(value = "修改时间", hidden = true)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String updateTime;

    /**
     * 登录/注册的特殊构造
     *
     * @param name     用户名
     * @param password 密码
     */
    public User(String name, String password) {
        this.name = name;
        this.password = password;
    }
}
